package ar.com.angrymachine.hunter;

import java.awt.Graphics;
import java.awt.Rectangle;

import ar.com.angrymachine.hunter.activities.InfoActivity;

public abstract class Activity
{
	public ActivitySet container = null;
	protected boolean dead = false;
	public boolean visible = true;
	
    public abstract String getDescription();
    public abstract String getActionText();
    public abstract void update(int delta, boolean action, boolean timeIsRunning);
    public abstract void paint(Graphics g, Rectangle activityArea);
    
    // called when the activity is being added into the visible set of an activityset
    public void onAddToActive(ActivitySet set)
    {
    	
    }
    
    public void onFinished()
    {
    }
    
    protected void end()
    {
    	end(false);
    }
    
    protected void end(boolean showInfo)
    {
    	dead = true;
    	if(showInfo)
    	{
    		visible = false;
    		container.replaceActivity(this, new InfoActivity(this));
    	}
    	else
    	{
    		container.removeActivity(this);
    	}
    }
    
    public boolean isCompleted()
    {
    	return dead;
    }
    
    public boolean consumesTime()
    {
        return true;
    }
        
    public boolean isRunning()
    {
        return Game.current.getRunningActivity() == this;
    }
}
